from pydantic import BaseModel
from typing import Optional
from uuid import UUID


class DictionaryTypeCreate(BaseModel):
    code: str
    name: str
    description: Optional[str] = None


class DictionaryTypeUpdate(BaseModel):
    name: Optional[str] = None
    description: Optional[str] = None


class DictionaryTypeRead(BaseModel):
    code: str
    name: str
    description: Optional[str] = None

    class Config:
        from_attributes = True


class DictionaryItemCreate(BaseModel):
    type_code: str
    code: str
    name: str
    enabled: bool = True
    order_index: int = 0


class DictionaryItemUpdate(BaseModel):
    code: Optional[str] = None
    name: Optional[str] = None
    enabled: Optional[bool] = None
    order_index: Optional[int] = None


class DictionaryItemRead(BaseModel):
    id: UUID
    type_code: str
    code: str
    name: str
    enabled: bool
    order_index: int

    class Config:
        from_attributes = True
